minecraftfandomcom-20200223-history
NBT Tags
NBT tags are used to specify information for items and entities created with the "/give", "/summon", "/tellraw" (for the JSON message), "/fill", "/blockdata''{Until 1.13}'", "/setblock", and "/clear" commands.'' Each Tag has the format :. Tag names are case-sensitive. The payloads of List Tags are enclosed in square brackets ..., with each additional unnamed Tag separated by a comma. The payloads of Compound Tags are enclosed in braces {...}, with each additional Named Tag separated by a comma - Note that the entire entity data tag is itself an unnamed Compound Tag. You can find a lot of tag names, especially in entities and block entities by using the "/data get entity" or /data get block command. How To Get Them? To get the NBT tag of a specific entity (for example, creeper), you use the command /date get entity @etype=creeper,limit=1 to get the full data of the creeper itself. For more specific selectors, see Commands Tag Basics Structure of a Tag First off, each tag has three parts: :tagType (byte, 0-12) :name (TAG_String) :payload When using commands, the tagType is figured out based on the given name, and the payload is what follows the colon - basically its value. The payload ought to fit the expected syntax. So a tag expecting an integer will not accept a string. Number types can be denoted with a letter at the end of the value (such as 0b for a byte). Without a letter, the code assumes an integer, which works fine for most numbers but behaves differently. Using a literal integer like this to exceed a type's expected range simply wraps the number back to 0 at the limit. Tag Types ;00 TAG_End :Unnamed, no payload, unusable in commands. Used in data storage to mark the end of TAG_Compound. ;01 TAG_Byte :'''Payload: A single signed byte (8 bits) :Ranges from -128 to 127. Used for many booleans. :In Commands: ...b or ...B ;02 TAG_Short :Payload: A single signed short integer (2 bytes, big endian) :Ranges from -215 to 215-1 :In Commands: ...s or ...S ;03 TAG_Int :Payload: A single signed integer (4 bytes, big endian) :Ranges from -231 to 231-1 :In Commands: A literal number without a decimal ;04 TAG_Long :Payload: A single signed long integer (8 bytes, big endian) :Ranges from -263 to 263-1 :In Commands: ...l or ...L ;05 TAG_Float :Payload: A floating-point number (4 bytes, big endian, IEEE 754-2008, single precision) :Maxes around 1038.23, or 1.698x1038 :In Commands: ...f or ...F, decimal or no decimal ;06 TAG_Double :Payload: A floating-point number (8 bytes, big endian, IEEE 754-2008, double precision) :Maxes around 10307.95, or 8.913x10307 :In Commands: ...d, ...D, or a decimal number ;07 TAG_Byte_Array :Payload: Unnamed TAG_Int (length), then an array of bytes of unspecified format. The length of this array is bytes. :In Commands: , , ... :( is determined by the length of the given array) ;08 TAG_String :Payload: Unnamed TAG_Short (length), then an array of bytes of length . defining a string in UTF-8 format. :In Commands: "" :( is determined by the length of the given text) :Note that as is usual with most strings, if quotes are to be included within the string, escape codes (\") must be used for the inner quotes in commands. ;09 TAG_List :Payload: Unnamed TAG_Byte (tagId), unnamed TAG_Int (length), then a sequential list of unnamed Tags of type . The length of this array is Tags. :In Commands: , ... :( is determined by the length of the given list) ;10 TAG_Compound :Payload: A sequential list of unique Named Tags. This array is terminated by a TAG_End. :Nested Compound Tags are terminated by their own internal End Tags. :In Commands: {: , : , ... } :(The terminating TAG_End is irrelevant to command usage) ;11 TAG_Int_Array :Payload: Unnamed TAG_Int (size), then an array of unnamed TAG_Ints. The length of this array is Tags. :An array of integers. :In Commands: , , ... :( is determined by the size of the given array) ;12 TAG_Long_Array :Payload: Unnamed TAG_Int (size), then an array of unnamed TAG_Longs. The length of this array is Tags. :In Commands: Used as , , ... :( is determined by the size of the given array) Tag Payloads The payload is the data a Tag carries. It might be a number or, in the case of Compound Tags and List Tags, other Tags. In using commands, one simply needs to avoid mismatching expected data types, keep values within expected ranges, and close all brackets ... and braces {...} that are opened. For a deeper understanding of payloads, it might help to look at what an example Compound Tag would look like in data. ON DISK: 00001010 00000000 00000011 01101000 01100001 01101101 00001000 00000000 00000111 01110000 01101001 01100111 01001110 01100001 01101101 01100101 00000000 00000110 01001000 01100001 01101101 01110000 01110101 01110011 00000011 00000000 00000101 01110110 01100001 01101100 01110101 01100101 00000000 00000000 00000000 01111000 00000000 DEC: 10 0 3 h a m 8 0 7 p i g N a m e 0 6 H a m p u s 3 0 5 v a l u e 0 0 0 120 0 __ ___ _____ _ ___ _____________ ___ ___________ _ ___ _________ _________ _ BYTES: 10 0 3 h a m 8 0 7 p i g N a m e 0 6 H a m p u s 3 0 5 v a l u e 0 0 0 120 0 |8: TAG_String | payload |3: TAG_Int | payload | TAG_End | 10:TAG_Compound| payload | This is understood in the following way. Recall that all named tags have a tagId (1 byte), a name (Unnamed TAG_String), and a payload. *The first byte of data read is the tagId. Above is 10, so this represents a TAG_Compound. The next two bytes read are the length of its name. (Two bytes because it expects a short - see Structure of a Tag above.) The given length is 3. Those next 3 bytes read ham. So far it's been revealed that the first Tag is a Compound Tag named "ham". Its payload is everything that follows, until TAG_End. **The next byte is 8, so this is a TAG_String. The upcoming unnamed TAG_String tells us it has the 7-byte name of "pigName". Its payload follows. ***The next short is 6, so the "pigName" has a value that's 6 bytes long. Those bytes read Hampus. The completed first Tag is TAG_String("name"):6 Hampus **The next byte is 3, so next is a TAG_Int. It has the 5-byte name of "value". Its payload follows in the next 4 bytes: 120. The next completed Tag is TAG_Int("value"): 120 **The next byte is 0, so next is a TAG_End. The completed Compound Tag is as follows: TAG_Compound("ham"): TAG_String("pigname"): 6 Hampus, TAG_Int("value"): 120, TAG_End Using a command to summon a pig with this example tag would look like this: /summon minecraft:pig ~ ~ ~ {ham:{pigname:"Hampus",value:120}} List of Entity Data Tags Minecraft code spawns entities with set Tags and values. Entities are themselves saved as tags within the world's chunk data. Every detail about an entity is stored in its data tag. All tags are referenced by the game's code to control entity behaviour. The following tags are common to all entities. Mobs The following tags are common to all mobs Mobs That Breed Mobs that can breed include Cows, Chickens, Pigs, Sheep, Villagers, Cats, and Dogs. Mobs That Raid Coming Soon Specific Mobs The following lists are specific to each mob Other To Be Removed The rest of this page is likely to be removed. Blocks ("/setblock" or "/fill") Containers Items: []The ID and other info of an item. |_ id: {}The ID of the item. |_ Slot: {}The slot number. Note that this starts at 0, not 1. |_ tag: {}Other info of the item. Items (/give) All Items Enchantments: Enchantments on the item. |_ An enchantement. (List) |_ id: The name of the enchantment. Cannot be a number. |_ lvl: The level of the enchant. Range is -32768 to 32767. display: Display properties. |_ Name: The Custom Name of the item. Range of characters that can be used seems to be infinite. |_ Name: ["{\"text\":\"enter custom name here\"}"] |_ color: The Custom Color of Leather Armor. |_ Lore: The description of an item. Separate lines of text with a comma after the bracket, prior to the last quotation mark |_ Lore: ["{\"text\":\"a line of text\"}"] 'Potions' CustomPotionEffects: Custom effects that a potion will have. |_ A potion effect. |_ Id: The ID of the effect. |_ Duration: The duration of the potion effect. |_ Amplifier: The potency (+1) of the effect. Kept at 0 to keep a level 1 effect. |_ Ambient: (0/1) 0 is false, 1 is true. True if the effect is provided by a beacon and thus should be less intrusive on screen. 'Written Book' author: The author of the book. title: The title of the book. pages: The pages in the book. |_ A page. Separate pages with a comma. Tools Unbreakable: (0b/1b) 0b is false, 1b is true. If value is 1b, the tool will never lose durability. CanDestroy: What blocks this tool can destroy when in adventure mode. |_ A block ID. CanPlaceOn: What blocks can be placed on in adventure mode. |_ A block ID. Title and Tellraw /title: /title (PlayerName) (sub)title {text:"PutTextHere",color:"PutColorHere"},(Optional){text:"MoreTextHere",color"PutColorHere"} (Add [] to enclose if doing multiple text tags) /tellraw: /tellraw (PlayerName) {text:"PutTextHere",color:"PutColorHere"},(Optional){text:"PutTextHere",color:"PutColorHere"} (Add [] to enclose if doing multiple text tags) Category:Game Mechanics Category:Game terms